import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

// import ElementUI from 'element-ui';
// import 'element-ui/lib/theme-chalk/index.css';

// import {Button} from 'element-ui' 

// Vue.use(Button);
import  { Row,Col,Button,Form,FormItem,Input,Message }  from "element-ui"

Vue.config.productionTip = false

// Vue.use(ElementUI);
Vue.prototype.$message = Message;


// 加全局钩子做路由登录判断
router.beforeEach((to,from,next)=>{
  document.title = `${to.meta.title}`
  const  role = localStorage.getItem('admin')  
  console.log(role)
  // const val = JSON.parse(role)
  // 这个方法不安全  
  const val = eval("("+ role +")")
  console.log(val)
  if (val !==null) {
    const  timestamp = new Date() - val.time;
    if (timestamp>val.expire) {
      localStorage.removeItem("admin")
      next('/login')

      return null;
    }
  }

  if (!val && to.path !== '/login') {
    next('/login')
  } else if(to.meta.permission){  //如果有权限的页面来访问
    // val.value === "admin"?next():next('/403')
  }else {
    //判断浏览器是否支持富文本编辑器


  }


  next();
})


new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
